Skip to main content

All Questions

1vote
2answers
900views

Jasmine spyOn not working properly on AngularJS directive

I'm working on an AngularJS app and I'm facing some problems with Jasmine's SpyOn in a concrete directive. The directive is quite simple, just call a service's method and when it resolves/rejects the ...
marc's user avatar
  • 537
0votes
0answers
109views

Unit Testing Keyup AngularJS

I am having the hardest time trying to figure out how to write unit tests for this simple directive. Any help would be greatly appreciated. Quick description: left and right arrow keys will change ...
user avatar
1vote
1answer
316views

Angular Directive function not being called in Unit Testing

I built a new directive in Angular (1.2.29) and I am trying to test it using karma, however I am having some problems when checking if the field is invalid, it seems it's always valid. Here is my ...
TiagoM's user avatar
  • 3,536
1vote
1answer
2kviews

Unit Testing Angular Attribute Directive

I am having some problems testing an AngularJS (1.5) Attribute restricted Directive. See the below example directive and following unit test, of which produces a broken unit test. Directive (...
Aaron Brewer's user avatar
2votes
1answer
586views

Unit tests for Angular js directive for ui-mask

I have a directive called maskUI .directive('uiMask', function () { return { template: '<input ui-mask="{{maskPattern}}"/>', replace: true, scope: true, ...
Nakul's user avatar
0votes
1answer
65views

Testing angularjs directive for attribute

I have the following directive which works fine and now I need to unit test it, (() => { angular .module('app.utilities') .directive('allowPattern', allowPatternDirective); function ...
digitalis's user avatar
0votes
0answers
438views

Angular Directive Karma Jasmine Testing with dependency injection

How can i test a directive that has a constant injected into them? Here is my Below Code. Im also Getting scope.element.node().getBoundingClientRect() to be 0 0 0 0. Please help. Directive (function ...
Keshore Durairaj's user avatar
0votes
1answer
23views

When unit testing a directive how to pass its controller

I am new to AngularJS and its unit test. Currently I am trying to test a directive with its controller in the template file: It's template: <div ng-controller = "SomeController" > <select ...
Lily's user avatar
0votes
0answers
426views

Angularjs - Test unit directive only numbers

I have a directives.js file with two directives and I would like apply unit testing necesary, to improve coverage, but I do not know how to do it This the directive.js file: (function () { 'use ...
Eladerezador's user avatar
1vote
1answer
627views

unit testing directive with link using controller

I'm trying to unit test my directive that set form validity depending on a controller variable. My directive code : angular.module('myModule',[]) .directive('myDirective', function() { ...
Patrick Lec's user avatar
0votes
1answer
2kviews

How to test an Image onload function within an $observe in karma

I have the following directive which tells me whether or not the image i'm trying to use has loaded successfully or not: return { restrict: 'A', scope: { imageLoad: '@' }, ...
gardni's user avatar
  • 1,424
0votes
1answer
61views

unit testing directive and isolatedScope not a function

I am trying to unit test a directive that was previously written and for my first unit test all I want to do is check a variable inside the scope of the directive. However, every time I try to run ...
Chevy Hungerford's user avatar
-1votes
2answers
904views

Get instance of directive controller with Angular/Jasmine

When unit testing angular directives, how can I grab an instance of the directive controller and assert certain data bindings on the controller? function myDirective() { return { restrict: 'E', ...
cusejuice's user avatar
3votes
1answer
988views

How do I test the HTML pointed to by the templateUrl of an angular directive?

I have a directive: app/controllers/battle.js angular.module('myModule') .controller('myController', ['$scope', function($scope){ $scope.sayHello = function(){console.log('hello');}; }])...
Caleb Jay's user avatar
7votes
2answers
4kviews

Testing angular mousedown, mousemove, mouseup

In the directives section of the angular docs They provide roughly this example of how to make a drag thing. My question is how would you test THEIR EXAMPLE/implementation: var startX = 0, ...
Andrew Luhring's user avatar

153050per page
close